{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Downloading Market and Fundamental Data with `yfinance`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Imports & Settings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:40:40.706465Z",
     "start_time": "2020-06-16T16:40:40.702831Z"
    }
   },
   "outputs": [],
   "source": [
    "import warnings\n",
    "warnings.filterwarnings('ignore')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:40:41.151854Z",
     "start_time": "2020-06-16T16:40:40.713025Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import yfinance as yf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How to work with a Ticker object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:17.821280Z",
     "start_time": "2020-06-16T16:43:17.809602Z"
    }
   },
   "outputs": [],
   "source": [
    "symbol = 'FB'\n",
    "ticker = yf.Ticker(symbol)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Show ticker info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:19.113524Z",
     "start_time": "2020-06-16T16:43:18.155573Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "zip                                                                        94025\n",
       "sector                                                    Communication Services\n",
       "fullTimeEmployees                                                          48268\n",
       "longBusinessSummary            Facebook, Inc. develops products that enable p...\n",
       "city                                                                  Menlo Park\n",
       "phone                                                               650-543-4800\n",
       "state                                                                         CA\n",
       "country                                                            United States\n",
       "companyOfficers                                                               []\n",
       "website                                                   http://investor.fb.com\n",
       "maxAge                                                                         1\n",
       "address1                                                        1601 Willow Road\n",
       "industry                                          Internet Content & Information\n",
       "previousClose                                                              232.5\n",
       "regularMarketOpen                                                         237.14\n",
       "twoHundredDayAverage                                                     199.804\n",
       "trailingAnnualDividendYield                                                 None\n",
       "payoutRatio                                                                    0\n",
       "volume24Hr                                                                  None\n",
       "regularMarketDayHigh                                                      238.46\n",
       "dtype: object"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series(ticker.info).head(20)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Get market data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:19.347776Z",
     "start_time": "2020-06-16T16:43:19.114865Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "DatetimeIndex: 1612 entries, 2020-06-10 09:30:00-04:00 to 2020-06-16 12:43:16-04:00\n",
      "Data columns (total 7 columns):\n",
      " #   Column        Non-Null Count  Dtype  \n",
      "---  ------        --------------  -----  \n",
      " 0   Open          1612 non-null   float64\n",
      " 1   High          1612 non-null   float64\n",
      " 2   Low           1612 non-null   float64\n",
      " 3   Close         1612 non-null   float64\n",
      " 4   Volume        1612 non-null   int64  \n",
      " 5   Dividends     1612 non-null   int64  \n",
      " 6   Stock Splits  1612 non-null   int64  \n",
      "dtypes: float64(4), int64(3)\n",
      "memory usage: 100.8 KB\n"
     ]
    }
   ],
   "source": [
    "data = ticker.history(period='5d',\n",
    "                      interval='1m',\n",
    "                      start=None,\n",
    "                      end=None,\n",
    "                      actions=True,\n",
    "                      auto_adjust=True,\n",
    "                      back_adjust=False)\n",
    "data.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### View company actions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:19.368729Z",
     "start_time": "2020-06-16T16:43:19.350236Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Dividends</th>\n",
       "      <th>Stock Splits</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Datetime</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [Dividends, Stock Splits]\n",
       "Index: []"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# show actions (dividends, splits)\n",
    "ticker.actions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:19.378823Z",
     "start_time": "2020-06-16T16:43:19.370774Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: Dividends, dtype: int64)"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.dividends"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:19.389513Z",
     "start_time": "2020-06-16T16:43:19.380921Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: Stock Splits, dtype: int64)"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.splits"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Annual and Quarterly Financial Statement Summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:24.146900Z",
     "start_time": "2020-06-16T16:43:24.140344Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [Open, High, Low, Close, Adj Close, Volume]\n",
       "Index: []"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.financials"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:24.317914Z",
     "start_time": "2020-06-16T16:43:24.311299Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [Open, High, Low, Close, Adj Close, Volume]\n",
       "Index: []"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.quarterly_financials"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Annual and Quarterly Balance Sheet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:24.720614Z",
     "start_time": "2020-06-16T16:43:24.710805Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [Open, High, Low, Close, Adj Close, Volume]\n",
       "Index: []"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.balance_sheet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:24.824566Z",
     "start_time": "2020-06-16T16:43:24.817598Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [Open, High, Low, Close, Adj Close, Volume]\n",
       "Index: []"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.quarterly_balance_sheet"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Annual and Quarterly Cashflow Statement"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:25.025226Z",
     "start_time": "2020-06-16T16:43:25.018976Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [Open, High, Low, Close, Adj Close, Volume]\n",
       "Index: []"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.cashflow"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:25.239013Z",
     "start_time": "2020-06-16T16:43:25.228781Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [Open, High, Low, Close, Adj Close, Volume]\n",
       "Index: []"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.quarterly_cashflow"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:25.456288Z",
     "start_time": "2020-06-16T16:43:25.446247Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [Open, High, Low, Close, Adj Close, Volume]\n",
       "Index: []"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.earnings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:26.325697Z",
     "start_time": "2020-06-16T16:43:26.315369Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [Open, High, Low, Close, Adj Close, Volume]\n",
       "Index: []"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.quarterly_earnings"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Sustainability: Environmental, Social and Governance (ESG)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:28.774348Z",
     "start_time": "2020-06-16T16:43:28.762044Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Value</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-3</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>palmOil</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>controversialWeapons</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>gambling</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>socialScore</th>\n",
       "      <td>18.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>nuclear</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>furLeather</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>alcoholic</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>gmo</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>catholic</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>socialPercentile</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>peerCount</th>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>governanceScore</th>\n",
       "      <td>12.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>environmentPercentile</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>animalTesting</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tobacco</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>totalEsg</th>\n",
       "      <td>32.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>highestControversy</th>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>esgPerformance</th>\n",
       "      <td>OUT_PERF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>coal</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>pesticides</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>adult</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>percentile</th>\n",
       "      <td>63.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>peerGroup</th>\n",
       "      <td>Software &amp; Services</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>smallArms</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>environmentScore</th>\n",
       "      <td>1.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>governancePercentile</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>militaryContract</th>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                     Value\n",
       "2020-3                                    \n",
       "palmOil                              False\n",
       "controversialWeapons                 False\n",
       "gambling                             False\n",
       "socialScore                          18.73\n",
       "nuclear                              False\n",
       "furLeather                           False\n",
       "alcoholic                            False\n",
       "gmo                                  False\n",
       "catholic                             False\n",
       "socialPercentile                         0\n",
       "peerCount                              100\n",
       "governanceScore                      12.41\n",
       "environmentPercentile                    0\n",
       "animalTesting                        False\n",
       "tobacco                              False\n",
       "totalEsg                             32.64\n",
       "highestControversy                       4\n",
       "esgPerformance                    OUT_PERF\n",
       "coal                                 False\n",
       "pesticides                           False\n",
       "adult                                False\n",
       "percentile                           63.64\n",
       "peerGroup              Software & Services\n",
       "smallArms                            False\n",
       "environmentScore                      1.51\n",
       "governancePercentile                     0\n",
       "militaryContract                     False"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.sustainability"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Analyst Recommendations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:33.592409Z",
     "start_time": "2020-06-16T16:43:33.581270Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "DatetimeIndex: 457 entries, 2012-06-29 06:50:00 to 2020-05-21 14:11:46\n",
      "Data columns (total 4 columns):\n",
      " #   Column      Non-Null Count  Dtype \n",
      "---  ------      --------------  ----- \n",
      " 0   Firm        457 non-null    object\n",
      " 1   To Grade    457 non-null    object\n",
      " 2   From Grade  457 non-null    object\n",
      " 3   Action      457 non-null    object\n",
      "dtypes: object(4)\n",
      "memory usage: 17.9+ KB\n"
     ]
    }
   ],
   "source": [
    "ticker.recommendations.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:35.425889Z",
     "start_time": "2020-06-16T16:43:35.410008Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Firm</th>\n",
       "      <th>To Grade</th>\n",
       "      <th>From Grade</th>\n",
       "      <th>Action</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-04-30 12:45:08</th>\n",
       "      <td>Morgan Stanley</td>\n",
       "      <td>Overweight</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-04-30 12:56:51</th>\n",
       "      <td>Stifel</td>\n",
       "      <td>Buy</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-04-30 13:07:11</th>\n",
       "      <td>Credit Suisse</td>\n",
       "      <td>Outperform</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-04-30 13:22:50</th>\n",
       "      <td>Oppenheimer</td>\n",
       "      <td>Outperform</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-04-30 13:37:07</th>\n",
       "      <td>UBS</td>\n",
       "      <td>Buy</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-04-30 13:52:56</th>\n",
       "      <td>Nomura Instinet</td>\n",
       "      <td>Buy</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-04-30 15:12:15</th>\n",
       "      <td>Guggenheim</td>\n",
       "      <td>Buy</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-04-30 16:13:15</th>\n",
       "      <td>SunTrust Robinson Humphrey</td>\n",
       "      <td>Buy</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-04-30 16:39:15</th>\n",
       "      <td>Canaccord Genuity</td>\n",
       "      <td>Buy</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-05-21 14:11:46</th>\n",
       "      <td>Stifel</td>\n",
       "      <td>Buy</td>\n",
       "      <td></td>\n",
       "      <td>main</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                           Firm    To Grade From Grade Action\n",
       "Date                                                                         \n",
       "2020-04-30 12:45:08              Morgan Stanley  Overweight              main\n",
       "2020-04-30 12:56:51                      Stifel         Buy              main\n",
       "2020-04-30 13:07:11               Credit Suisse  Outperform              main\n",
       "2020-04-30 13:22:50                 Oppenheimer  Outperform              main\n",
       "2020-04-30 13:37:07                         UBS         Buy              main\n",
       "2020-04-30 13:52:56             Nomura Instinet         Buy              main\n",
       "2020-04-30 15:12:15                  Guggenheim         Buy              main\n",
       "2020-04-30 16:13:15  SunTrust Robinson Humphrey         Buy              main\n",
       "2020-04-30 16:39:15           Canaccord Genuity         Buy              main\n",
       "2020-05-21 14:11:46                      Stifel         Buy              main"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.recommendations.tail(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Upcoming Events"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:38.209828Z",
     "start_time": "2020-06-16T16:43:38.199536Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Earnings Date</th>\n",
       "      <td>2020-07-22 00:00:00</td>\n",
       "      <td>2020-07-27 00:00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Earnings Average</th>\n",
       "      <td>1.37</td>\n",
       "      <td>1.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Earnings Low</th>\n",
       "      <td>0.97</td>\n",
       "      <td>0.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Earnings High</th>\n",
       "      <td>1.71</td>\n",
       "      <td>1.71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Revenue Average</th>\n",
       "      <td>17174200000</td>\n",
       "      <td>17174200000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Revenue Low</th>\n",
       "      <td>16156000000</td>\n",
       "      <td>16156000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Revenue High</th>\n",
       "      <td>19018000000</td>\n",
       "      <td>19018000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                    0                    1\n",
       "Earnings Date     2020-07-22 00:00:00  2020-07-27 00:00:00\n",
       "Earnings Average                 1.37                 1.37\n",
       "Earnings Low                     0.97                 0.97\n",
       "Earnings High                    1.71                 1.71\n",
       "Revenue Average           17174200000          17174200000\n",
       "Revenue Low               16156000000          16156000000\n",
       "Revenue High              19018000000          19018000000"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.calendar"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Option Expiration Dates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:41.571501Z",
     "start_time": "2020-06-16T16:43:41.470643Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('2020-06-18',\n",
       " '2020-06-25',\n",
       " '2020-07-01',\n",
       " '2020-07-09',\n",
       " '2020-07-16',\n",
       " '2020-07-23',\n",
       " '2020-07-30',\n",
       " '2020-08-20',\n",
       " '2020-09-17',\n",
       " '2020-11-19',\n",
       " '2020-12-17',\n",
       " '2021-01-14',\n",
       " '2021-03-18',\n",
       " '2021-06-17',\n",
       " '2022-01-20',\n",
       " '2022-06-16',\n",
       " '2022-09-15',\n",
       " '2026-02-20')"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ticker.options"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:43:59.679615Z",
     "start_time": "2020-06-16T16:43:59.677178Z"
    }
   },
   "outputs": [],
   "source": [
    "expiration = ticker.options[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:00.239200Z",
     "start_time": "2020-06-16T16:44:00.105014Z"
    }
   },
   "outputs": [],
   "source": [
    "options = ticker.option_chain(expiration)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:00.685877Z",
     "start_time": "2020-06-16T16:44:00.672070Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 71 entries, 0 to 70\n",
      "Data columns (total 14 columns):\n",
      " #   Column             Non-Null Count  Dtype         \n",
      "---  ------             --------------  -----         \n",
      " 0   contractSymbol     71 non-null     object        \n",
      " 1   lastTradeDate      71 non-null     datetime64[ns]\n",
      " 2   strike             71 non-null     float64       \n",
      " 3   lastPrice          71 non-null     float64       \n",
      " 4   bid                71 non-null     float64       \n",
      " 5   ask                71 non-null     float64       \n",
      " 6   change             71 non-null     float64       \n",
      " 7   percentChange      71 non-null     float64       \n",
      " 8   volume             71 non-null     int64         \n",
      " 9   openInterest       71 non-null     int64         \n",
      " 10  impliedVolatility  71 non-null     float64       \n",
      " 11  inTheMoney         71 non-null     bool          \n",
      " 12  contractSize       71 non-null     object        \n",
      " 13  currency           71 non-null     object        \n",
      "dtypes: bool(1), datetime64[ns](1), float64(7), int64(2), object(3)\n",
      "memory usage: 7.4+ KB\n"
     ]
    }
   ],
   "source": [
    "options.calls.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:06.108615Z",
     "start_time": "2020-06-16T16:44:06.081700Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>contractSymbol</th>\n",
       "      <th>lastTradeDate</th>\n",
       "      <th>strike</th>\n",
       "      <th>lastPrice</th>\n",
       "      <th>bid</th>\n",
       "      <th>ask</th>\n",
       "      <th>change</th>\n",
       "      <th>percentChange</th>\n",
       "      <th>volume</th>\n",
       "      <th>openInterest</th>\n",
       "      <th>impliedVolatility</th>\n",
       "      <th>inTheMoney</th>\n",
       "      <th>contractSize</th>\n",
       "      <th>currency</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>FB200619C00070000</td>\n",
       "      <td>2020-06-16 14:59:51</td>\n",
       "      <td>70.0</td>\n",
       "      <td>163.70</td>\n",
       "      <td>165.80</td>\n",
       "      <td>166.1</td>\n",
       "      <td>1.599991</td>\n",
       "      <td>0.987039</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>0.00001</td>\n",
       "      <td>True</td>\n",
       "      <td>REGULAR</td>\n",
       "      <td>USD</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>FB200619C00075000</td>\n",
       "      <td>2020-06-10 13:30:00</td>\n",
       "      <td>75.0</td>\n",
       "      <td>165.90</td>\n",
       "      <td>160.80</td>\n",
       "      <td>161.1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "      <td>0.00001</td>\n",
       "      <td>True</td>\n",
       "      <td>REGULAR</td>\n",
       "      <td>USD</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>FB200619C00080000</td>\n",
       "      <td>2020-06-15 19:59:00</td>\n",
       "      <td>80.0</td>\n",
       "      <td>151.90</td>\n",
       "      <td>155.80</td>\n",
       "      <td>156.1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>5</td>\n",
       "      <td>172</td>\n",
       "      <td>0.00001</td>\n",
       "      <td>True</td>\n",
       "      <td>REGULAR</td>\n",
       "      <td>USD</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>FB200619C00085000</td>\n",
       "      <td>2020-06-09 14:45:07</td>\n",
       "      <td>85.0</td>\n",
       "      <td>152.77</td>\n",
       "      <td>150.25</td>\n",
       "      <td>151.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>15</td>\n",
       "      <td>33</td>\n",
       "      <td>0.00001</td>\n",
       "      <td>True</td>\n",
       "      <td>REGULAR</td>\n",
       "      <td>USD</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>FB200619C00090000</td>\n",
       "      <td>2020-06-09 13:41:05</td>\n",
       "      <td>90.0</td>\n",
       "      <td>144.35</td>\n",
       "      <td>145.35</td>\n",
       "      <td>146.3</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2</td>\n",
       "      <td>24</td>\n",
       "      <td>0.00001</td>\n",
       "      <td>True</td>\n",
       "      <td>REGULAR</td>\n",
       "      <td>USD</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      contractSymbol       lastTradeDate  strike  lastPrice     bid    ask  \\\n",
       "0  FB200619C00070000 2020-06-16 14:59:51    70.0     163.70  165.80  166.1   \n",
       "1  FB200619C00075000 2020-06-10 13:30:00    75.0     165.90  160.80  161.1   \n",
       "2  FB200619C00080000 2020-06-15 19:59:00    80.0     151.90  155.80  156.1   \n",
       "3  FB200619C00085000 2020-06-09 14:45:07    85.0     152.77  150.25  151.0   \n",
       "4  FB200619C00090000 2020-06-09 13:41:05    90.0     144.35  145.35  146.3   \n",
       "\n",
       "     change  percentChange  volume  openInterest  impliedVolatility  \\\n",
       "0  1.599991       0.987039       1             7            0.00001   \n",
       "1  0.000000       0.000000       1            12            0.00001   \n",
       "2  0.000000       0.000000       5           172            0.00001   \n",
       "3  0.000000       0.000000      15            33            0.00001   \n",
       "4  0.000000       0.000000       2            24            0.00001   \n",
       "\n",
       "   inTheMoney contractSize currency  \n",
       "0        True      REGULAR      USD  \n",
       "1        True      REGULAR      USD  \n",
       "2        True      REGULAR      USD  \n",
       "3        True      REGULAR      USD  \n",
       "4        True      REGULAR      USD  "
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "options.calls.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:07.169578Z",
     "start_time": "2020-06-16T16:44:07.147867Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 67 entries, 0 to 66\n",
      "Data columns (total 14 columns):\n",
      " #   Column             Non-Null Count  Dtype         \n",
      "---  ------             --------------  -----         \n",
      " 0   contractSymbol     67 non-null     object        \n",
      " 1   lastTradeDate      67 non-null     datetime64[ns]\n",
      " 2   strike             67 non-null     float64       \n",
      " 3   lastPrice          67 non-null     float64       \n",
      " 4   bid                67 non-null     float64       \n",
      " 5   ask                67 non-null     float64       \n",
      " 6   change             67 non-null     float64       \n",
      " 7   percentChange      67 non-null     float64       \n",
      " 8   volume             67 non-null     int64         \n",
      " 9   openInterest       67 non-null     int64         \n",
      " 10  impliedVolatility  67 non-null     float64       \n",
      " 11  inTheMoney         67 non-null     bool          \n",
      " 12  contractSize       67 non-null     object        \n",
      " 13  currency           67 non-null     object        \n",
      "dtypes: bool(1), datetime64[ns](1), float64(7), int64(2), object(3)\n",
      "memory usage: 7.0+ KB\n"
     ]
    }
   ],
   "source": [
    "options.puts.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Data Download with proxy server"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can use a proxy server to avoid having your IP blacklisted as illustrated below (but need an actual PROXY_SERVER)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:40:43.509453Z",
     "start_time": "2020-06-16T16:40:43.504575Z"
    }
   },
   "outputs": [],
   "source": [
    "PROXY_SERVER = 'PROXY_SERVER'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following will only work with proper PROXY_SERVER..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:40:43.519559Z",
     "start_time": "2020-06-16T16:40:43.514966Z"
    }
   },
   "outputs": [],
   "source": [
    "# msft = yf.Ticker(\"MSFT\")\n",
    "\n",
    "# msft.history(proxy=PROXY_SERVER)\n",
    "# msft.get_actions(proxy=PROXY_SERVER)\n",
    "# msft.get_dividends(proxy=PROXY_SERVER)\n",
    "# msft.get_splits(proxy=PROXY_SERVER)\n",
    "# msft.get_balance_sheet(proxy=PROXY_SERVER)\n",
    "# msft.get_cashflow(proxy=PROXY_SERVER)\n",
    "# msgt.option_chain(proxy=PROXY_SERVER)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Downloading multiple symbols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:10.965260Z",
     "start_time": "2020-06-16T16:44:10.895176Z"
    }
   },
   "outputs": [],
   "source": [
    "tickers = yf.Tickers('msft aapl goog')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:11.062874Z",
     "start_time": "2020-06-16T16:44:11.056379Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "yfinance.Tickers object <MSFT,AAPL,GOOG>"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tickers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:11.953471Z",
     "start_time": "2020-06-16T16:44:11.210166Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "zip                                                                  98052\n",
       "sector                                                          Technology\n",
       "fullTimeEmployees                                                   144000\n",
       "longBusinessSummary      Microsoft Corporation develops, licenses, and ...\n",
       "city                                                               Redmond\n",
       "                                               ...                        \n",
       "sharesShortPriorMonth                                             47763253\n",
       "category                                                              None\n",
       "fiveYearAverageReturn                                                 None\n",
       "regularMarketPrice                                                  192.89\n",
       "logo_url                           https://logo.clearbit.com/microsoft.com\n",
       "Length: 122, dtype: object"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series(tickers.tickers.MSFT.info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:12.174151Z",
     "start_time": "2020-06-16T16:44:11.958148Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Volume</th>\n",
       "      <th>Dividends</th>\n",
       "      <th>Stock Splits</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-05-18</th>\n",
       "      <td>313.17</td>\n",
       "      <td>316.50</td>\n",
       "      <td>310.32</td>\n",
       "      <td>314.96</td>\n",
       "      <td>33843100</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-05-19</th>\n",
       "      <td>315.03</td>\n",
       "      <td>318.52</td>\n",
       "      <td>313.01</td>\n",
       "      <td>313.14</td>\n",
       "      <td>25432400</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-05-20</th>\n",
       "      <td>316.68</td>\n",
       "      <td>319.52</td>\n",
       "      <td>316.52</td>\n",
       "      <td>319.23</td>\n",
       "      <td>27876200</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-05-21</th>\n",
       "      <td>318.66</td>\n",
       "      <td>320.89</td>\n",
       "      <td>315.87</td>\n",
       "      <td>316.85</td>\n",
       "      <td>25672200</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-05-22</th>\n",
       "      <td>315.77</td>\n",
       "      <td>319.23</td>\n",
       "      <td>315.35</td>\n",
       "      <td>318.89</td>\n",
       "      <td>20450800</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-05-26</th>\n",
       "      <td>323.50</td>\n",
       "      <td>324.24</td>\n",
       "      <td>316.50</td>\n",
       "      <td>316.73</td>\n",
       "      <td>31380500</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-05-27</th>\n",
       "      <td>316.14</td>\n",
       "      <td>318.71</td>\n",
       "      <td>313.09</td>\n",
       "      <td>318.11</td>\n",
       "      <td>28236300</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-05-28</th>\n",
       "      <td>316.77</td>\n",
       "      <td>323.44</td>\n",
       "      <td>315.63</td>\n",
       "      <td>318.25</td>\n",
       "      <td>33390200</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-05-29</th>\n",
       "      <td>319.25</td>\n",
       "      <td>321.15</td>\n",
       "      <td>316.47</td>\n",
       "      <td>317.94</td>\n",
       "      <td>38399500</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-01</th>\n",
       "      <td>317.75</td>\n",
       "      <td>322.35</td>\n",
       "      <td>317.21</td>\n",
       "      <td>321.85</td>\n",
       "      <td>20197800</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-02</th>\n",
       "      <td>320.75</td>\n",
       "      <td>323.44</td>\n",
       "      <td>318.93</td>\n",
       "      <td>323.34</td>\n",
       "      <td>21910700</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-03</th>\n",
       "      <td>324.66</td>\n",
       "      <td>326.20</td>\n",
       "      <td>322.30</td>\n",
       "      <td>325.12</td>\n",
       "      <td>26122800</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-04</th>\n",
       "      <td>324.39</td>\n",
       "      <td>325.62</td>\n",
       "      <td>320.78</td>\n",
       "      <td>322.32</td>\n",
       "      <td>21890100</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-05</th>\n",
       "      <td>323.35</td>\n",
       "      <td>331.75</td>\n",
       "      <td>323.23</td>\n",
       "      <td>331.50</td>\n",
       "      <td>34312600</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-08</th>\n",
       "      <td>330.25</td>\n",
       "      <td>333.60</td>\n",
       "      <td>327.32</td>\n",
       "      <td>333.46</td>\n",
       "      <td>23913600</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-09</th>\n",
       "      <td>332.14</td>\n",
       "      <td>345.61</td>\n",
       "      <td>332.01</td>\n",
       "      <td>343.99</td>\n",
       "      <td>36928100</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-10</th>\n",
       "      <td>347.90</td>\n",
       "      <td>354.77</td>\n",
       "      <td>346.09</td>\n",
       "      <td>352.84</td>\n",
       "      <td>41662900</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-11</th>\n",
       "      <td>349.31</td>\n",
       "      <td>351.06</td>\n",
       "      <td>335.48</td>\n",
       "      <td>335.90</td>\n",
       "      <td>50415600</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-12</th>\n",
       "      <td>344.72</td>\n",
       "      <td>347.80</td>\n",
       "      <td>334.22</td>\n",
       "      <td>338.80</td>\n",
       "      <td>50001500</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-15</th>\n",
       "      <td>333.25</td>\n",
       "      <td>345.68</td>\n",
       "      <td>332.58</td>\n",
       "      <td>342.99</td>\n",
       "      <td>34642900</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-06-16</th>\n",
       "      <td>351.46</td>\n",
       "      <td>353.02</td>\n",
       "      <td>344.72</td>\n",
       "      <td>351.71</td>\n",
       "      <td>23023184</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Open    High     Low   Close    Volume  Dividends  Stock Splits\n",
       "Date                                                                         \n",
       "2020-05-18  313.17  316.50  310.32  314.96  33843100          0             0\n",
       "2020-05-19  315.03  318.52  313.01  313.14  25432400          0             0\n",
       "2020-05-20  316.68  319.52  316.52  319.23  27876200          0             0\n",
       "2020-05-21  318.66  320.89  315.87  316.85  25672200          0             0\n",
       "2020-05-22  315.77  319.23  315.35  318.89  20450800          0             0\n",
       "2020-05-26  323.50  324.24  316.50  316.73  31380500          0             0\n",
       "2020-05-27  316.14  318.71  313.09  318.11  28236300          0             0\n",
       "2020-05-28  316.77  323.44  315.63  318.25  33390200          0             0\n",
       "2020-05-29  319.25  321.15  316.47  317.94  38399500          0             0\n",
       "2020-06-01  317.75  322.35  317.21  321.85  20197800          0             0\n",
       "2020-06-02  320.75  323.44  318.93  323.34  21910700          0             0\n",
       "2020-06-03  324.66  326.20  322.30  325.12  26122800          0             0\n",
       "2020-06-04  324.39  325.62  320.78  322.32  21890100          0             0\n",
       "2020-06-05  323.35  331.75  323.23  331.50  34312600          0             0\n",
       "2020-06-08  330.25  333.60  327.32  333.46  23913600          0             0\n",
       "2020-06-09  332.14  345.61  332.01  343.99  36928100          0             0\n",
       "2020-06-10  347.90  354.77  346.09  352.84  41662900          0             0\n",
       "2020-06-11  349.31  351.06  335.48  335.90  50415600          0             0\n",
       "2020-06-12  344.72  347.80  334.22  338.80  50001500          0             0\n",
       "2020-06-15  333.25  345.68  332.58  342.99  34642900          0             0\n",
       "2020-06-16  351.46  353.02  344.72  351.71  23023184          0             0"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tickers.tickers.AAPL.history(period=\"1mo\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:16.719522Z",
     "start_time": "2020-06-16T16:44:16.472839Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[*********************100%***********************]  3 of 3 completed\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>Close</th>\n",
       "      <th>Dividends</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Open</th>\n",
       "      <th>Stock Splits</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">2020-05-18</th>\n",
       "      <th>AAPL</th>\n",
       "      <td>314.959991</td>\n",
       "      <td>0.0</td>\n",
       "      <td>316.500000</td>\n",
       "      <td>310.320007</td>\n",
       "      <td>313.170013</td>\n",
       "      <td>0</td>\n",
       "      <td>33843100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GOOG</th>\n",
       "      <td>1383.939941</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1392.324951</td>\n",
       "      <td>1354.250000</td>\n",
       "      <td>1361.750000</td>\n",
       "      <td>0</td>\n",
       "      <td>1824000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MSFT</th>\n",
       "      <td>184.396439</td>\n",
       "      <td>0.0</td>\n",
       "      <td>185.682849</td>\n",
       "      <td>183.449080</td>\n",
       "      <td>185.234102</td>\n",
       "      <td>0</td>\n",
       "      <td>35306600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2020-05-19</th>\n",
       "      <th>AAPL</th>\n",
       "      <td>313.140015</td>\n",
       "      <td>0.0</td>\n",
       "      <td>318.519989</td>\n",
       "      <td>313.010010</td>\n",
       "      <td>315.029999</td>\n",
       "      <td>0</td>\n",
       "      <td>25432400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GOOG</th>\n",
       "      <td>1373.484985</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1392.000000</td>\n",
       "      <td>1373.484985</td>\n",
       "      <td>1386.996948</td>\n",
       "      <td>0</td>\n",
       "      <td>1280600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2020-06-15</th>\n",
       "      <th>GOOG</th>\n",
       "      <td>1419.849976</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1424.800049</td>\n",
       "      <td>1387.920044</td>\n",
       "      <td>1390.800049</td>\n",
       "      <td>0</td>\n",
       "      <td>1503900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MSFT</th>\n",
       "      <td>188.940002</td>\n",
       "      <td>0.0</td>\n",
       "      <td>190.820007</td>\n",
       "      <td>184.009995</td>\n",
       "      <td>184.580002</td>\n",
       "      <td>0</td>\n",
       "      <td>32712500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">2020-06-16</th>\n",
       "      <th>AAPL</th>\n",
       "      <td>351.709991</td>\n",
       "      <td>0.0</td>\n",
       "      <td>353.020111</td>\n",
       "      <td>344.720001</td>\n",
       "      <td>351.459991</td>\n",
       "      <td>0</td>\n",
       "      <td>23023184</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GOOG</th>\n",
       "      <td>1444.350098</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1455.020020</td>\n",
       "      <td>1425.900146</td>\n",
       "      <td>1445.219971</td>\n",
       "      <td>0</td>\n",
       "      <td>840528</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MSFT</th>\n",
       "      <td>193.929993</td>\n",
       "      <td>0.0</td>\n",
       "      <td>195.580002</td>\n",
       "      <td>191.475006</td>\n",
       "      <td>192.889999</td>\n",
       "      <td>0</td>\n",
       "      <td>21810226</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>63 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       Close  Dividends         High          Low  \\\n",
       "Date                                                                \n",
       "2020-05-18 AAPL   314.959991        0.0   316.500000   310.320007   \n",
       "           GOOG  1383.939941        0.0  1392.324951  1354.250000   \n",
       "           MSFT   184.396439        0.0   185.682849   183.449080   \n",
       "2020-05-19 AAPL   313.140015        0.0   318.519989   313.010010   \n",
       "           GOOG  1373.484985        0.0  1392.000000  1373.484985   \n",
       "...                      ...        ...          ...          ...   \n",
       "2020-06-15 GOOG  1419.849976        0.0  1424.800049  1387.920044   \n",
       "           MSFT   188.940002        0.0   190.820007   184.009995   \n",
       "2020-06-16 AAPL   351.709991        0.0   353.020111   344.720001   \n",
       "           GOOG  1444.350098        0.0  1455.020020  1425.900146   \n",
       "           MSFT   193.929993        0.0   195.580002   191.475006   \n",
       "\n",
       "                        Open  Stock Splits    Volume  \n",
       "Date                                                  \n",
       "2020-05-18 AAPL   313.170013             0  33843100  \n",
       "           GOOG  1361.750000             0   1824000  \n",
       "           MSFT   185.234102             0  35306600  \n",
       "2020-05-19 AAPL   315.029999             0  25432400  \n",
       "           GOOG  1386.996948             0   1280600  \n",
       "...                      ...           ...       ...  \n",
       "2020-06-15 GOOG  1390.800049             0   1503900  \n",
       "           MSFT   184.580002             0  32712500  \n",
       "2020-06-16 AAPL   351.459991             0  23023184  \n",
       "           GOOG  1445.219971             0    840528  \n",
       "           MSFT   192.889999             0  21810226  \n",
       "\n",
       "[63 rows x 7 columns]"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tickers.history(period='1mo').stack(-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:19.208338Z",
     "start_time": "2020-06-16T16:44:19.026948Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[*********************100%***********************]  2 of 2 completed\n"
     ]
    }
   ],
   "source": [
    "data = yf.download(\"SPY AAPL\", start=\"2020-01-01\", end=\"2020-01-05\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:19.271313Z",
     "start_time": "2020-06-16T16:44:19.249642Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "DatetimeIndex: 2 entries, 2020-01-02 to 2020-01-03\n",
      "Data columns (total 12 columns):\n",
      " #   Column             Non-Null Count  Dtype  \n",
      "---  ------             --------------  -----  \n",
      " 0   (Adj Close, AAPL)  2 non-null      float64\n",
      " 1   (Adj Close, SPY)   2 non-null      float64\n",
      " 2   (Close, AAPL)      2 non-null      float64\n",
      " 3   (Close, SPY)       2 non-null      float64\n",
      " 4   (High, AAPL)       2 non-null      float64\n",
      " 5   (High, SPY)        2 non-null      float64\n",
      " 6   (Low, AAPL)        2 non-null      float64\n",
      " 7   (Low, SPY)         2 non-null      float64\n",
      " 8   (Open, AAPL)       2 non-null      float64\n",
      " 9   (Open, SPY)        2 non-null      float64\n",
      " 10  (Volume, AAPL)     2 non-null      int64  \n",
      " 11  (Volume, SPY)      2 non-null      int64  \n",
      "dtypes: float64(10), int64(2)\n",
      "memory usage: 208.0 bytes\n"
     ]
    }
   ],
   "source": [
    "data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:19.986819Z",
     "start_time": "2020-06-16T16:44:19.536937Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[*********************100%***********************]  3 of 3 completed\n"
     ]
    }
   ],
   "source": [
    "data = yf.download(\n",
    "        tickers = \"SPY AAPL MSFT\", # list or string\n",
    "\n",
    "        # use \"period\" instead of start/end\n",
    "        # valid periods: 1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max\n",
    "        # (optional, default is '1mo')\n",
    "        period = \"5d\",\n",
    "\n",
    "        # fetch data by interval (including intraday if period < 60 days)\n",
    "        # valid intervals: 1m,2m,5m,15m,30m,60m,90m,1h,1d,5d,1wk,1mo,3mo\n",
    "        # (optional, default is '1d')\n",
    "        interval = \"1m\",\n",
    "\n",
    "        # group by ticker (to access via data['SPY'])\n",
    "        # (optional, default is 'column')\n",
    "        group_by = 'ticker',\n",
    "\n",
    "        # adjust all OHLC automatically\n",
    "        # (optional, default is False)\n",
    "        auto_adjust = True,\n",
    "\n",
    "        # download pre/post regular market hours data\n",
    "        # (optional, default is False)\n",
    "        prepost = True,\n",
    "\n",
    "        # use threads for mass downloading? (True/False/Integer)\n",
    "        # (optional, default is True)\n",
    "        threads = True,\n",
    "\n",
    "        # proxy URL scheme use use when downloading?\n",
    "        # (optional, default is None)\n",
    "        proxy = None\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:20.637708Z",
     "start_time": "2020-06-16T16:44:20.611809Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "DatetimeIndex: 4284 entries, 2020-06-10 04:00:00-04:00 to 2020-06-16 12:44:17-04:00\n",
      "Data columns (total 15 columns):\n",
      " #   Column          Non-Null Count  Dtype  \n",
      "---  ------          --------------  -----  \n",
      " 0   (MSFT, Open)    3101 non-null   float64\n",
      " 1   (MSFT, High)    3101 non-null   float64\n",
      " 2   (MSFT, Low)     3101 non-null   float64\n",
      " 3   (MSFT, Close)   3101 non-null   float64\n",
      " 4   (MSFT, Volume)  3101 non-null   float64\n",
      " 5   (AAPL, Open)    3287 non-null   float64\n",
      " 6   (AAPL, High)    3287 non-null   float64\n",
      " 7   (AAPL, Low)     3287 non-null   float64\n",
      " 8   (AAPL, Close)   3287 non-null   float64\n",
      " 9   (AAPL, Volume)  3287 non-null   float64\n",
      " 10  (SPY, Open)     4125 non-null   float64\n",
      " 11  (SPY, High)     4125 non-null   float64\n",
      " 12  (SPY, Low)      4125 non-null   float64\n",
      " 13  (SPY, Close)    4125 non-null   float64\n",
      " 14  (SPY, Volume)   4125 non-null   float64\n",
      "dtypes: float64(15)\n",
      "memory usage: 535.5 KB\n"
     ]
    }
   ],
   "source": [
    "data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:21.533793Z",
     "start_time": "2020-06-16T16:44:21.348927Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[*********************100%***********************]  1 of 1 completed\n"
     ]
    }
   ],
   "source": [
    "from pandas_datareader import data as pdr\n",
    "\n",
    "import yfinance as yf\n",
    "yf.pdr_override()\n",
    "\n",
    "# download dataframe\n",
    "data = pdr.get_data_yahoo('SPY',\n",
    "                          start='2017-01-01',\n",
    "                          end='2019-04-30',\n",
    "                          auto_adjust=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:23.025885Z",
     "start_time": "2020-06-16T16:44:23.000315Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-04-23</th>\n",
       "      <td>290.679993</td>\n",
       "      <td>293.140015</td>\n",
       "      <td>290.420013</td>\n",
       "      <td>292.880005</td>\n",
       "      <td>287.015472</td>\n",
       "      <td>52246600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-04-24</th>\n",
       "      <td>292.790009</td>\n",
       "      <td>293.160004</td>\n",
       "      <td>292.070007</td>\n",
       "      <td>292.230011</td>\n",
       "      <td>286.378540</td>\n",
       "      <td>50392900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-04-25</th>\n",
       "      <td>292.119995</td>\n",
       "      <td>292.779999</td>\n",
       "      <td>290.730011</td>\n",
       "      <td>292.049988</td>\n",
       "      <td>286.202118</td>\n",
       "      <td>57770900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-04-26</th>\n",
       "      <td>292.100006</td>\n",
       "      <td>293.489990</td>\n",
       "      <td>291.239990</td>\n",
       "      <td>293.410004</td>\n",
       "      <td>287.534882</td>\n",
       "      <td>50916400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-04-29</th>\n",
       "      <td>293.510010</td>\n",
       "      <td>294.450012</td>\n",
       "      <td>293.410004</td>\n",
       "      <td>293.869995</td>\n",
       "      <td>287.985657</td>\n",
       "      <td>57197700</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  Open        High         Low       Close   Adj Close  \\\n",
       "Date                                                                     \n",
       "2019-04-23  290.679993  293.140015  290.420013  292.880005  287.015472   \n",
       "2019-04-24  292.790009  293.160004  292.070007  292.230011  286.378540   \n",
       "2019-04-25  292.119995  292.779999  290.730011  292.049988  286.202118   \n",
       "2019-04-26  292.100006  293.489990  291.239990  293.410004  287.534882   \n",
       "2019-04-29  293.510010  294.450012  293.410004  293.869995  287.985657   \n",
       "\n",
       "              Volume  \n",
       "Date                  \n",
       "2019-04-23  52246600  \n",
       "2019-04-24  50392900  \n",
       "2019-04-25  57770900  \n",
       "2019-04-26  50916400  \n",
       "2019-04-29  57197700  "
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# auto_adjust = True\n",
    "data.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-16T16:44:23.278256Z",
     "start_time": "2020-06-16T16:44:23.261253Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Adj Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-04-23</th>\n",
       "      <td>290.679993</td>\n",
       "      <td>293.140015</td>\n",
       "      <td>290.420013</td>\n",
       "      <td>292.880005</td>\n",
       "      <td>287.015472</td>\n",
       "      <td>52246600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-04-24</th>\n",
       "      <td>292.790009</td>\n",
       "      <td>293.160004</td>\n",
       "      <td>292.070007</td>\n",
       "      <td>292.230011</td>\n",
       "      <td>286.378540</td>\n",
       "      <td>50392900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-04-25</th>\n",
       "      <td>292.119995</td>\n",
       "      <td>292.779999</td>\n",
       "      <td>290.730011</td>\n",
       "      <td>292.049988</td>\n",
       "      <td>286.202118</td>\n",
       "      <td>57770900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-04-26</th>\n",
       "      <td>292.100006</td>\n",
       "      <td>293.489990</td>\n",
       "      <td>291.239990</td>\n",
       "      <td>293.410004</td>\n",
       "      <td>287.534882</td>\n",
       "      <td>50916400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-04-29</th>\n",
       "      <td>293.510010</td>\n",
       "      <td>294.450012</td>\n",
       "      <td>293.410004</td>\n",
       "      <td>293.869995</td>\n",
       "      <td>287.985657</td>\n",
       "      <td>57197700</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  Open        High         Low       Close   Adj Close  \\\n",
       "Date                                                                     \n",
       "2019-04-23  290.679993  293.140015  290.420013  292.880005  287.015472   \n",
       "2019-04-24  292.790009  293.160004  292.070007  292.230011  286.378540   \n",
       "2019-04-25  292.119995  292.779999  290.730011  292.049988  286.202118   \n",
       "2019-04-26  292.100006  293.489990  291.239990  293.410004  287.534882   \n",
       "2019-04-29  293.510010  294.450012  293.410004  293.869995  287.985657   \n",
       "\n",
       "              Volume  \n",
       "Date                  \n",
       "2019-04-23  52246600  \n",
       "2019-04-24  50392900  \n",
       "2019-04-25  57770900  \n",
       "2019-04-26  50916400  \n",
       "2019-04-29  57197700  "
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# auto_adjust = False\n",
    "data.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": true,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
